
allChannelConfigfn() 
function allChannelConfigfn() {
    $.ajax({
        type: "post",
        url: root.dockingplatform.allChannelConfig,
        cache: false,  //禁用缓存
        dataType: "json",
        data: {

        },
        //传入组装的参数
        success: function (data) {
            if(data.errorCode=="0") {
                var dataInter=data.data;
                var interText = doT.template($("#ascription_bob").text());
                $.each(dataInter, function (inx, data2) {
                    var haha = '<option value="' + data2.customerCode +'" >' + data2.customerName + '</option>';
                    $('#parentCustomerName').append(haha)
                })
            }
        }
    })
}
/*获取收货地址*/
discountdata(123)
function discountdata (val) {
    if(val==123){
        //初始化 省
        var user_data = {
            level: '101',
            // memberId:'10258',
        }
        var succCallBack = function (data, status, response) {
            console.log(data)
            if(data.errorCode=="0"){
                var tab_data=data.list;
                if(tab_data==''){
                    cer+='<option value=""></option>'
                    $("#getArea").html(cer);
                }else{
                    var cer="<option value=''>请选择收货区域</option>"
                    for(var i=0; i<tab_data.length; i++){
                        cer+='<option value="'+tab_data[i].code+'">'+tab_data[i].name+'</option>'
                    }
                    $("#getArea").html(cer);
                }
            }
        };
        web.doAjax(root.member.getLowerAddress,'post',user_data, succCallBack);
    }else if(val==1){
        //市
        var special=$('#getArea').val()
        if(special==""){
            var cer="<option value=''>请选择收货位置</option>"
            $("#getPlace").html(cer);
        }else {
            var user_data = {
                level: '102',
                // memberId:'10258',
                parentCode:special
            }
            var succCallBack = function (data, status, response) {
                if(data.errorCode=="0"){
                    var tab_data=data.list;
                    if(tab_data==''){
                        cer+='<option value=""></option>'
                        $("#getPlace").html(cer);
                    }else{
                        var cer="<option value=''>请选择收货位置</option>"
                        for(var i=0; i<tab_data.length; i++){
                            cer+='<option value="'+tab_data[i].code+'">'+tab_data[i].name+'</option>'
                        }
                        $("#getPlace").html(cer);
                    }
                }
            };
            web.doAjax(root.member.getLowerAddress,'post',user_data, succCallBack);
        }
    }
}
/*表格渲染*/
var dataSource = new Array();
//table的数据源
var table;   //table对象
dataSource = [];
function orderList(data) {
    dataSource.splice(0, dataSource.length);//清空数组
    if(data.data.data!=null){
    $.each(data.data.data, function (i, field) {
        var rowData = new Array();
        rowData.push(field.orderId);
        rowData.push(field.parentCustomerName);
        rowData.push(field.providerName);
        rowData.push(field.createdOrderAt);
        rowData.push(field.finalTotalAmount);
        rowData.push(field.warningRemark);
        rowData.push(field.id);
        dataSource.push(rowData);
    });
   
}
initDataTable(dataSource);
    function initDataTable(dataSource) {
        var dttable = $('#datatable').dataTable(); // 初始化dataTable，清空上一个值
        dttable.fnClearTable(); //清空一下table
        dttable.fnDestroy(); //还原初始化了的datatable
        $("#datatable").DataTable({
            "order": [[ 1, "desc" ]],
            "autoWidth": false,
            "ordering": false,
            "searching": false,
            "paging": false,
            "retrieve": true,
            "destroy": true,
            "bAutoWidth": true,
            "bLengthChange": true,
            "aLengthMenu": [5, 10, 25, 50],
            "oLanguage": {
                "sLengthMenu": "每页显示 _MENU_ 条记录",
                "sZeroRecords": "抱歉， 没有找到",
                "sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
                "sInfoEmpty": "没有数据",
                "sInfoFiltered": "(从 _MAX_ 条数据中检索)",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "前一页",
                    "sNext": "后一页",
                    "sLast": "尾页"
                },
                "sZeroRecords": "没有检索到数据",
                "sProcessing": "<img src='./loading.gif' />",
            },
            data: dataSource,
            columnDefs: [
                {
                    "visible": true,
                    "targets": 0
                },
                {
                    "render": function (data, type, row, meta) {
                        var val = row[0]
                        if (val == undefined) {
                            val = ''
                        }
                        return val;
                    },
                    "targets": 0
                },
                {
                    "render": function (data, type, row, meta) {
                        var val = row[1]
                        if (val == undefined) {
                            val = ''
                        }
                        return val;
                    },
                    "targets": 1
                },
                {
                    "render": function (data, type, row, meta) {
                        var val = row[2]
                        if (val == undefined) {
                            val = ''
                        }
                        return val;
                    },
                    "targets":2
                },
                {
                    "render": function (data, type, row) {
                        var val = row[3]
                        if (val == undefined) {
                            val = ''
                        }
                        return val;
                    },
                    "targets": 3
                },
                {
                    "render": function (data, type, row) {
                        var val = row[4]
                        if (val == undefined) {
                            val = ''
                        }
                        return val;
                    },
                    "targets": 4
                },
                {
                    "render": function (data, type, row) {
                        var val = '<span  class="consigneetitle" title="'+row[5]+'">'+row[5]+'</div>';
                        return val
                    },
                    "targets": 5
                },

                {
                    "render": function (data, type, row) {
                            var val = '<span class="list"><a onclick="orderInfo(\'订单详情\',\'orderalertdetail.html\',\''+row[6]+'\',\''+row[0]+'\')">订单详情</a></span><br><span><a onclick="closeOrderWarn(\'' + row[6] + '\',\'' + row[0] + '\')">解除预警</a></span>';
                            return val;
                    },
                    "targets": 6
                }
            ]
        });
        //权限控制函数
        power()
    };
}

//解除预警
function closeOrderWarn(warnId,orderId) {
    var curInd = layer.confirm(
        '<span>是否解除订单预警？</span>'+'<br/>', {title:'提示',btn: ['确定', '取消']}, function(index){
            $.ajax({
                url:root.serviceProviderManagement.closeOrderWarn,
                cache: false,  //禁用缓存
                type: "POST",
                dataType:'json',
                contentType: "application/json",
                data: JSON.stringify({
                    "warnId":warnId,//预警id
                    "orderId":orderId,//订单号
                    "operatorId":JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,//操作人
                    "operatorName":JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,//操作姓名
                }),
                success: function (data) {
                    if(Number(data.code)==0){
                        $.Huimodalalert("解除成功",2000);
                        location.replace(location.href);
                    }else {
                        $.Huimodalalert(data.msg,2000);
                    }
                },
                error: function () {
                    $.Huimodalalert('失败！',2000);
                }
            });
            layer.close(curInd);

        },function(){
            layer.close(curInd);

        });
}
function getList(){
    var a
    if($("#paid_amount_min").val()!=null && $("#paid_amount_max").val()!=null){
        if (parseFloat($("#paid_amount_max").val())<=parseFloat($("#paid_amount_min").val())){
            var s = "输入金额应大于第1个输入框";
            $.Huimodalalert(s,1000);
            return false;
        }
    }
    var per={};
            per = {
                pageNum: 1, //当前页码
                pageSize: 50,//每页显示条数
                "parentCustomerCode":$("#parentCustomerName").val(),//渠道商名称
                "providerName":$("#providerName").val(),//服务商名称
                "isWarningRemark":$("#isremakes").val(),//有无备注
                "channelOrderId":$("#dorderCode").val(),//对方订单
                "orderId":$("#orderCode").val(),//我方订单号
                "productCode":$("#SKUCode").val(),//商品code
                "orderStatus":$("#dealState").val(),//订单状态
                "createdOrderBegin":$("#timemin").val(),//下单时间开始
                "createdOrderEnd":$("#timemax").val(),//下单时间 结束
                "pushOrderBegin":$("#tuisongmin").val(),//推送时间 开始
                "pushOrderEnd":$("#tuisongmax").val(),//推送时间 结束
                "receiverName":$("#consignee").val(),//收货人姓名
                "receiverPhone":$("#phoneNum").val(),//收货人手机
                "receiverProvince":$("#getArea").val(),
                "receiverCity":$("#getPlace").val(),
                "sentType":$("#sent_type").val(),//配送类型
                "finalTotalAmountLow":$("#paid_amount_min").val(),//订单金额低
                "finalTotalAmountHigh":$("#paid_amount_max").val(),//订单金额 高
                "uploadProofStatus":$("#uploadProofStatus").val(),//收货凭证
          
            };

    $.ajax({
        contentType: "application/json",
        type: "POST",
        url: root.serviceProviderManagement.listWarningOrder,
        cache: false,  //禁用缓存
        dataType: "json",
        data: JSON.stringify(per),
        success: function (result) {
            isIng = false;
            orderList(result);
            $('.M-box3').pagination({
                pageCount: result.data.pageCount,
                jump: true,
                coping: true,
                prevContent: '上页',
                nextContent: '下页',
                callback: function (api) {
                    var perdd={};
                            perdd = {
                                pageNum: api.getCurrent(), //当前页码
                                pageSize: 50,//每页显示条数
                                "parentCustomerCode":$("#parentCustomerName").val(),//渠道商名称
                                "providerName":$("#providerName").val(),//服务商名称
                                "isWarningRemark":$("#isremakes").val(),//有无备注
                                "channelOrderId":$("#dorderCode").val(),//对方订单
                                "orderId":$("#orderCode").val(),//我方订单号
                                "productCode":$("#SKUCode").val(),//商品code
                                "orderStatus":$("#dealState").val(),//订单状态
                                "createdOrderBegin":$("#timemin").val(),//下单时间开始
                                "createdOrderEnd":$("#timemax").val(),//下单时间 结束
                                "pushOrderBegin":$("#tuisongmin").val(),//推送时间 开始
                                "pushOrderEnd":$("#tuisongmax").val(),//推送时间 结束
                                "receiverName":$("#consignee").val(),//收货人姓名
                                "receiverPhone":$("#phoneNum").val(),//收货人手机
                                "receiverProvince":$("#getArea").val(),
                                "receiverCity":$("#getPlace").val(),
                                "sentType":$("#sent_type").val(),//配送类型
                                "finalTotalAmountLow":$("#paid_amount_min").val(),//订单金额低
                                "finalTotalAmountHigh":$("#paid_amount_max").val(),//订单金额 高
                                "uploadProofStatus":$("#uploadProofStatus").val(),//收货凭证
                            
                            };
                    $.ajax({
                        contentType: "application/json",
                        type: "POST",
                        url:root.serviceProviderManagement.listWarningOrder,
                        cache: false,  //禁用缓存
                        dataType: "json",
                        data: JSON.stringify(perdd),
                        success: function (result) {
                            orderList(result);
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                        }
                    });
                }
            });
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
        }
    });
}
/*跳转订单详情*/
function orderInfo(title,url,orderBaseId,orderId){
    sessionStorage.setItem("orderBaseId",orderBaseId);
    sessionStorage.setItem("orderId",orderId);
    var index = layer.open({
        type: 2,
        title: title,
        content: url
    });
    layer.full(index);
}
